package com.alex.jdbc.transaction.service.impl;

import com.alex.jdbc.transaction.service.BookShopService;
import com.alex.jdbc.transaction.service.Cashier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("cashier")
public class CashierImpl implements Cashier {

    @Autowired
    private BookShopService bookShopService;

    @Transactional
    @Override
    public void checkout(String username, List<String> isbnList) {

        for (String isbn : isbnList) {
            bookShopService.purchase(username, isbn);
        }
    }
}
